import pandas as pd
from mysql_in import mysql_sql_df
from mysql_in import mysql_to_sql
# 显示所有列
pd.set_option('display.max_columns', None)
def dim_film():
    # 获取film
    df_film=mysql_sql_df('film')
    # 获取language
    df_language=mysql_sql_df('language')
    # 两表按照左链接合并
    df_film=pd.merge(left=df_film,right=df_language,on='language_id',how='left')

    # 获取category
    df_category=mysql_sql_df('category')
    # 两表按照左链接合并
    df_film=pd.merge(left=df_film,right=df_category,on='film_id',how='left')

    # 节选字段
    df_film=df_film[['film_id','title','description','release_year','category','name','rental_duration','rental_rate','length','replacement_cost','rating','last_update']]
    # 插入mysql
    mysql_to_sql(df_film,'dim_film')


